#pragma once

#include "dllmain.h"

#include <map>
#include <vector>
#include <string>

BEGIN_NAMESPACE_CPPX

class _CPPX_API fuStringCommand
{
    struct para_t {
        uint        pos;
        std::string val;

        para_t(uint pos_) : pos(pos_) {}
    };
    std::vector<para_t> m_paras;
    uint                m_parai;
    bool                m_quote;
    std::string            m_text;
    std::string            m_text_sql;

public:
    virtual ~fuStringCommand(void);
    fuStringCommand(void);

    fuStringCommand(std::string const & v);
    fuStringCommand(const char * v);

    void operator = (std::string const & v);
    void operator = (const char * v);

    void InitPara( std::string const &v );

    fuStringCommand & operator << (cstr cond);
    fuStringCommand & operator << (std::string cond);

    template<class T>
    fuStringCommand & operator << (T cond){
        if( m_parai < m_paras.size() ){
            std::stringstream ss;
            ss << cond;
            m_paras[m_parai++].val = ss.str();
        }
        return *this;
    }

    std::string str(void);

    operator std::string (void);
};

END_NAMESPACE_CPPX
